if (islogin()) {
    $('#op').click(function () {
        var button1=[
            {
                text:'添加',
                onClick:function () {
                    window.location.href='add_class.html';
                }
            }
        ];
        var button2=[{
            text:'取消',
        }];
        var groups=[button1,button2];
        $$.actions(groups);
    });
    $.ajax({
        url:'../../requests/teacher/select_classes.php',
        type:'POST',
        success:function (data) {
            if (data.length < 1) {
                $$.alert('您还又没创建班级');
            }
            else for (var i=0;i<data.length;i++){
                var dom="<div class='list-block'><ul>"+
                    "<li class='item-content item-link click_class\'>"+
                    "<div class='item-inner'>"+
                    "<div class='item-title'>班级代码</div>"+
                    "<div class='item-after class_num'>"+data[i].num+"</div>"+
                    "</div>"+
                    "</li>"+
                    "<li class='item-content'>"+
                    "<div class='item-inner'>"+
                    "<div class='item-title'>班级名称</div>"+
                    "<div class='item-after'>"+data[i].name+"</div>"+
                    "</div>"+
                    "</li>"+
                    "<li class='item-content'>"+
                    "<div class='item-inner'>"+
                    "<div class='item-title'>人数</div>"+
                    "<div class='item-after'>"+data[i].sum+"</div>"+
                    "</div> </li> " +
                "<li class='item-content item-link'>" +
                "<div class='item-inner'>" +
                    "<div class='item-title'></div>"+
                    "<div class='item-after'><a class='button edit_btn'>编辑</a></div></div></li>"+
                    "</ul></div>"
                $('.content').append(dom);
            }
        }
    });
    $('.content').on('click','.edit_btn',function () {
        var class_num=$(this).parent().parent().parent().parent().find('.class_num').html();
        window.location.href='edit_class.html?'+class_num;
    });
    $('.content').on('click','.click_class',function () {
        var class_num=$(this).find('.class_num').html();
        window.location.href="details_stu.html?"+class_num;
    });
}
else {
    window.location.href='../../index.html';
}